package com.tanqing.ddd.domain.command;


import com.tanqing.ddd.domain.aggregate.Parkting;
import com.tanqing.ddd.domain.event.EventQueue;
import com.tanqing.ddd.domain.repository.ParktingRepository;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

@Component

public class CheckinCommandHandle {


    @Resource
    private ParktingRepository parktingRepository;

    public boolean handle(EventQueue eventQueue, CheckinCommand command) {

        Parkting parkting = parktingRepository.fundByPlate(command.getPlate());

        boolean res = parkting.handle(eventQueue, command);
        if (res) {
            parktingRepository.save(parkting);
        }
        return res;
    }
}
